ActiveSync Scripting
The following is a nice? sample for an automation task. This batch will be executed every time a device connects to your PC via ActiveSync. You will need the itsutils.
As you can read, the batch (script) first tries to check, if it has already been run on the device. This is done by looking for a file called “\OnConnect.done”. In real, the batch deletes a local file (line 13) “OnConnect.done” and then simply copies the file from the device (line16). If the file is found, this device has been already processed (line 17) and the batch gos on with line 66.
If the file is not found, the batch continues with setting the registry changes. It uses saved REG files and the nice tool pregutl to do it remotely (line 22 to 24). After doing the changes, the device will be queried for different registry keys which will be saved to database.txt for later use. The registry keys platform (line 29) and version (line 30) are available on all devices, but OSBuildInfo (line 59) and system (line 48) are only available on CK3x or 7xx.
So in line 33, we try to find the model string for CK3x devices and in line 39 for CN2 devices. In line 43 and 44 we will use the saved model names to jump over the part, that is only valid for PPC (7xx): dump psminfo.txt into database.txt. The OSBuildInfo registry is only been executed for CK3x models.
Finally we put a OnConnect.done onto the device, so we later know, that it was handled. At the very end, we sync the time of the device with the PC.
-
@echo off
-
cls
-
echo ######################################################################
-
echo # autosetup script for ITC devices (CK3x, CN2x, 7xx) #
-
echo # will set registry keys for numberig format, timezone and DST #
-
echo # creates a database.txt file with relevant data of the devices #
-
echo ######################################################################
-
D:
-
cd \OnConnect
-
echo "checking if already processed device..."
-
REM check if already processed
-
REM delete the check file
-
@del OnConnect.done >NULL
-
echo onconnect >OnConnect.bak
-
REM try to load the checkfile
-
@pget \OnConnect.done >NULL
-
if exist OnConnect.done goto OldDevice
-
goto NewDevice
-
:NewDevice
-
echo "####### New Device #######"
-
echo "setting region..."
-
pregutl @region.reg
-
echo "setting timezone..."
-
pregutl @timezone.reg
-
REM put device in database
-
echo. >>database.txt
-
echo "building database entries..."
-
echo ####### >>database.txt
-
pregutl HKEY_LOCAL_MACHINE\Platform >>database.txt
-
pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\Version >>database.txt
-
REM only PPC device have Intermec\System
-
REM check for ck3x
-
pregutl HKEY_LOCAL_MACHINE\Platform | FINDSTR "CK3"
-
if errorlevel 1 goto cont1
-
if errorlevel 0 set Model="CK3X"
-
:cont1
-
REM CN2 does not have OSBuildInfo as CK3x
-
REM check for CN2
-
pregutl HKEY_LOCAL_MACHINE\Platform | FINDSTR "CN2"
-
if errorlevel 1 goto cont2
-
if errorlevel 0 set Model="CN2"
-
:cont2
-
if "%Model%"==""CK3X"" goto CK3x
-
if "%Model%"==""CN2"" goto CN2
-
REM PPC only
-
:NoCK3x
-
:NoCN2
-
pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\System >>database.txt
-
REM look for PSMInfo
-
del PSMInfo.txt
-
pget "\Flash File Store\PSMInfo.txt"
-
if NOT EXIST PSMInfo.txt goto NoPSM
-
type PSMInfo.txt >>database.txt
-
echo. >>database.txt
-
REM if you like to get a listing of the cabfiles uncomment following line
-
REM pdir "\Flash File Store\Persistent Copy\Cabfiles\*.*" >>database.txt
-
goto NoPSM
-
:CK3x
-
pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Intermec\OSBuildInfo >>database.txt
-
:NoPSM
-
:CN2
-
pput OnConnect.bak \OnConnect.done
-
REM the database will be filled once REM reg changes will also done only for new devices
-
REM psynctime will be executed always
-
:OldDevice
-
REM uncomment, if you like to get a list of installed apps
-
REM pregutl HKEY_LOCAL_MACHINE\SOFTWARE\Apps >>database.txt
-
echo "syncing time..."
-
psynctime
-
@echo on
-
REM pause DEBUG
-
:EXIT
-
exit
Here is a sample of the database.txt
####### [HKLM\Platform] CodeName="SeaRay" Model="730A" Name="Intermec 740" Software Build Number="4.95.1" Target=dword:00000001 Type=dword:00000002 [HKLM\SOFTWARE\Intermec\Version] IVA="iva_4.03.35.0998" LScanner="1d-35-0-21" [HKLM\SOFTWARE\Intermec\System] BLVer="4.95" FPGAVer="1.15" KBVer="1.06" MFGCode="730A1E4004001000" OSVer="4.20.0" SN="004210400008" PSM Build v4.03 (05-12-2006) ####### [HKLM\Platform] Build="3.00.00.0103" CodeName="Gimli" Model="CN2A" Name="Intermec CN2" Software Build Number="3.00.00.0103" Type=dword:00000002 [HKLM\SOFTWARE\Intermec\Version] IVA="iva_4.02.31.0691" ####### [HKLM\Platform] Build="3.00.00.0103" CodeName="Gimli" Model="CN2A" Name="Intermec CN2" Software Build Number="3.00.00.0103" Type=dword:00000002 [HKLM\SOFTWARE\Intermec\Version] IVA="iva_4.02.31.0691" ...